package com.hust.together.xmpp;

import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;

public class serverConnection {

	public static String OPENFIRE_SERVERIP = "192.168.1.1";
	public static int OPENFIRE_PORT = 5222;
	private static XMPPConnection conn = null;
	
	private static void openConnection() {

		ConnectionConfiguration connConfig = new ConnectionConfiguration(
				OPENFIRE_SERVERIP, OPENFIRE_PORT);
		XMPPConnection conn = new XMPPConnection(connConfig);
		try {
			conn.connect();
		} catch (XMPPException e) {
			e.printStackTrace();
		}
	}
	public static XMPPConnection getConnection() {
		if (conn == null) {
			openConnection();

		}
		return conn;
	}

	public static void closeConnection() {
		conn.disconnect();
		conn = null;
	}
		
}